package com.cv.framework.security.core.service;

import com.cv.system.api.permission.PermissionApi;
import lombok.AllArgsConstructor;
import org.apache.dubbo.config.annotation.DubboReference;

import static com.cv.framework.security.core.utils.SecurityFrameworkUtil.getLoginUserId;

/**
 * 默认的 {@link SecurityFrameworkService} 实现类
 *
 * @author Charles_XDXD
 */
@AllArgsConstructor
public class SecurityFrameworkServiceImpl implements SecurityFrameworkService {

    @DubboReference
    private final PermissionApi permissionApi;

    @Override
    public boolean hasRole(String role) {
        return hasAnyRoles(role);
    }

    @Override
    public boolean hasAnyRoles(String... roles) {
        return permissionApi.hasAnyRoles(getLoginUserId(), roles);
    }
    
}
